package com.ruigi.control;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruigi.pojo.Category;
import com.ruigi.pojo.R;
import com.ruigi.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryControl {
    @Autowired
    private CategoryService categoryService;


    @PostMapping
    public R<String> save(@RequestBody Category category) {

        return categoryService.save1(category);
    }

    //分页查询
    @GetMapping("/page")
    public R<Page> page(int page, int pageSize) {


        return categoryService.page1(page, pageSize);
    }

    //删除
    @DeleteMapping
    private R<String> delete(Long ids) {

        System.out.println(11);
        categoryService.remove(ids);

        return R.success("删除成功！");
    }

    @PutMapping
    public R<String> update(@RequestBody Category category) {
        ;


        return categoryService.update(category);
    }

    @GetMapping("/list")
    public R<List<Category>> type(Category category) {


        return categoryService.type(category);
    }

}
